﻿$(document).ready(
    function() {

        if(!window.localStorage){
            new UserPrompt('您所使用的浏览器版本太低，或不支持本页面，请更换浏览器并重试！');
        }else{
        	numbers = $('#tts_input').bind('input propertychange',function(){
        		numbers = $('#tts_input').val();
        		ncount = numbers.split(',');
        		$('.sound_tip').text(ncount.length+"/200");
        	});
			$('#ttsBtn').click(function(){
				numbers = $('#tts_input').val();
	        	ncount = numbers.split(',');
				if(ncount.length>100){
					new UserPrompt("号码数量超过100了！");
				}
				else{
					sendShortMessage();
				}
				
			});
		}
    });
	function sendShortMessage(){
		baseurl=location.protocol+'//'+location.host;//嘟嘟平台环境根路径 
		template = $('#phone_input').val();
		$.ajax({
			type:"post",
			url:baseurl+"/SMSv4/postSms.do",
			datatype:"json",
			contentType:'application/x-www-form-urlencoded;charset=utf-8',
			data:{'app_key':'99653B0C7EC6897C2F426C0E13A9D66C',
				  'cust_account':'1464225803014_8866',
				  'timestamp':'1481505050643',
				  'sign':'919fd3e1be6709a82a654d5c0c343d5cde019887',
				  'ext_terminalCode':'18060249922',
				  'called':numbers,
				  'msg_id':"",
				  'template_code':template,
				  'template_params':'[56849801]'
				 
				  },
			beforeSend:function(){
				loadPrompt=new LoadPrompt("短信发送中...");
			},
			success:function(json){
				var result = jQuery.parseJSON(json);
				if(result['result']=='0'){
					new UserPrompt("短信发送成功");
				}
				else{
					new UserPrompt(result['describe']);
				}
					
			},
			error: function (json) {
                            new UserPrompt("连接异常，请稍后再试！"+json['describe']);
                        },
			complete: function () {
							if(loadPrompt){
								loadPrompt.close();
								loadPrompt=null;
							}
                        }
		});
	};
	
